#include <stdio.h>

int func1(int a, int b, int c)
{
    switch(b)
    {
    case '+':
        return a + c;
    case '-':
        return a - c;
    case '*':
        return a * c;
    case '/':
        if (c != 0)
            return a / c;
    }
    return 0;
}




int main()
{
    FILE *p = fopen("a.txt", "r");
    FILE *p1 = fopen("b.txt", "w");
    while(1)
    {
        int a = 0;
        char b = 0;
        int c = 0;

        //fscanf是从一个文件中读取字符串，并转义
        fscanf(p, "%d%c%d=", &a, &b, &c);
        
        
        if(feof(p))
            break;

        printf("%d, %c, %d\n", a, b, c);

        fprintf(p1, "%d%c%d=%d\n", a, b, c, func1(a, b, c));
    }
    fclose(p);
    fclose(p1);
    return 0;
}
